from HTMLTestRunner.HTMLTestRunner import HTMLTestRunner
import unittest
from mail2 import sendEmail

# 1.扫描3条用例
# 加载器,  pattern是匹配器，专门匹配Test开头的文件
tests = unittest.defaultTestLoader.discover("D:\pythonProject\ 理财自动化测试", pattern="Test*.py")

# 2.创建运行器
runner = HTMLTestRunner(
    title = "测试报告",
    description="中央财务系统测试报告",
    verbosity=2, #  报告的详细程度
    stream=open(file="测试报告.html", mode="w+", encoding="utf-8")
)


# 3.执行测试并生成测试报告
runner.run(tests)
sendEmail("D:\pythonProject\理财自动化测试\测试报告.html", "1508935167@qq.com")


